<template>
	<view class="container">
		<view class="withdraw-card">
			<view class="withdraw-title">可申请结算</view>
			<view class="withdraw-amount">{{$formatAmount(2263)}}</view>
			<button class="withdraw-btn" @click="applyWithdraw">申请提现</button>

			<view class="withdraw-info">
				<view class="withdraw-info-item">
					<text class="withdraw-info-label">订单数量</text>
					<text class="withdraw-info-value">{{$formatAmount(1250, true)}}</text>
				</view>
				<view class="withdraw-info-item">
					<text class="withdraw-info-label">刷新时间</text>
					<text class="withdraw-info-value">2025-04-10 12:23</text>
				</view>
			</view>
		</view>

		<view class="withdraw-history">
			<view class="history-title">提现记录</view>

			<view class="history-item" v-for="(item, index) in withdrawRecords" :key="index">
				<view class="history-item-title">
					<text class="history-item-type">余额提现</text>
					<text class="history-item-date">2024-04-05 16:29:05</text>
				</view>
				<view>
					<view :class="['history-item-status', item.status]">{{ item.statusText }}</view>
					<view class="history-item-amount">20.00</view>
				</view>
			</view>
		</view>

		<view class="back-to-top" @click="backToTop">↑</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				withdrawRecords: [{
						status: 'status-pending',
						statusText: '待审核'
					},
					{
						status: 'status-pending',
						statusText: '待审核'
					},
					{
						status: 'status-rejected',
						statusText: '拒绝'
					},
					{
						status: 'status-approved',
						statusText: '通过'
					},
					{
						status: 'status-approved',
						statusText: '通过'
					},
				],
			}
		},
		methods: {
			applyWithdraw() {
				uni.navigateTo({
					url: "/pages/payouts/payoutsStatus/payoutsStatus"
				})
				return
				uni.showToast({
					title: '提现申请已提交',
					icon: 'none',
				});
			},
			backToTop() {
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 300,
				});
			},
		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
		background: #f8f8f8;
	}

	.container {
		width: 100%;
		height: 100%;
		background: #f8f8f8;
	}


	.withdraw-card {
		background-color: #2979ff;
		color: white;
		border-radius: 20rpx;
		padding: 40rpx;
		box-sizing: border-box;
		margin: 30rpx;
		position: relative;

		.withdraw-title {
			font-size: 24rpx;
			margin-bottom: 10rpx;
			opacity: 0.8;
		}

		.withdraw-amount {
			font-size: 48rpx;
			// font-weight: bold;
		}

		.withdraw-btn {
			position: absolute;
			top: 40rpx;
			right: 40rpx;
			background-color: white;
			color: #2979ff;
			border: none;
			border-radius: 40rpx;
			padding: 0rpx 40rpx;
			font-size: 28rpx;
		}

		.withdraw-info {
			display: flex;
			justify-content: space-between;
			margin-top: 40rpx;
			font-size: 24rpx;

			.withdraw-info-item {
				display: flex;
				flex-direction: column;

				.withdraw-info-label {
					opacity: 0.8;
					margin-bottom: 5rpx;
				}

				.withdraw-info-value {
					font-size: 30rpx;
					// font-weight: bold;
				}
			}
		}
	}

	.withdraw-history {
		background-color: white;
		border-radius: 20rpx;
		padding: 30rpx;
		margin: 20rpx 30rpx;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

		.history-title {
			font-size: 36rpx;
			padding-bottom: 20rpx;
			color: #333;
			font-weight: bold;
		}

		.history-item {
			display: flex;
			justify-content: space-between;
			padding: 30rpx 0;
			border-bottom: 1px solid #f0f0f0;

			&:last-child {
				border-bottom: none;
			}

			.history-item-title {
				display: flex;
				flex-direction: column;
				

				.history-item-type {
					font-size: 32rpx;
					color: #333;
					margin-bottom: 10rpx;
				}

				.history-item-date {
					font-size: 24rpx;
					color: #999;
				}
			}

			.history-item-status {
				font-size: 28rpx;
				text-align: right;

				&.status-pending {
					color: #2979ff;
				}

				&.status-rejected {
					color: #f44336;
				}

				&.status-approved {
					color: #4caf50;
				}
			}

			.history-item-amount {
				font-size: 32rpx;
				font-weight: bold;
				color: #333;
			}
		}
	}

	.back-to-top {
		position: absolute;
		right: 30rpx;
		bottom: 70rpx;
		width: 80rpx;
		height: 80rpx;
		background-color: rgba(0, 0, 0, 0.1);
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
	}
</style>